package com.xjgc.eip.panel.controller;


import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xjgc.common.entity.ReturnResult;
import com.xjgc.eip.panel.entity.ZxjEipDnbDbcs;
import com.xjgc.eip.panel.mapper.ZxjEipDnbDbcsMapper;
import com.xjgc.eip.panel.service.ZxjEipDnbDbcsService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wxy
 * @since 2019-11-07
 */
@RestController
@RequestMapping("/zxjEipDnbDbcs")
public class ZxjEipDnbDbcsController {
    @Autowired
    private ZxjEipDnbDbcsService zxjEipDnbDbcsService;
    @Autowired
    private ZxjEipDnbDbcsMapper zxjEipDnbDbcsMapper;
    @RequestMapping("paramIntro")
    public ReturnResult paramIntro(Integer amount,@RequestHeader("supplierCode")String supplierCode){
        amount=(amount==null)?1:amount;
        Map map=new HashMap();
        map.put("amount",amount);
        map.put("SUPPLIER_CODE",supplierCode);
        List<ZxjEipDnbDbcs> list = zxjEipDnbDbcsMapper.selectNo(map);
        /*ZxjEipDnbDbcs zxjEipDnbDbcs = new ZxjEipDnbDbcs();
        zxjEipDnbDbcs.setIoflag(1);
        QueryWrapper<ZxjEipDnbDbcs> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(zxjEipDnbDbcs);
        queryWrapper.orderByAsc("\"CREATE_TIME\"");
        Page<ZxjEipDnbDbcs> page = new Page<ZxjEipDnbDbcs>(1,amount);*/
        ReturnResult returnResult = new ReturnResult();
//        List<ZxjEipDnbDbcs> list = zxjEipDnbDbcsService.page(page,queryWrapper).getRecords();
        returnResult.setData(list);
        if(list!=null&&list.size()>0){
            for (ZxjEipDnbDbcs zed:list) {
                zed.setIoflag(0);
                zed.setGrabTime(new Date());
            }
            zxjEipDnbDbcsService.updateBatchById(list);
        }

        return returnResult;
    }
    @RequestMapping("list")
    public Result list( @RequestHeader(value = "supplierCode" ,required = false)String supplierCode, ZxjEipDnbDbcs zxjEipDnbDbcs){
        String testCode = zxjEipDnbDbcs.getTestCode();
        //testCode = testCode==null?"201911051059500104011080999":testCode;
        supplierCode=supplierCode==null?"1000069096":supplierCode;
        List<ZxjEipDnbDbcs> list = zxjEipDnbDbcsService.list(testCode,supplierCode);
        Page page = new Page();
        page.setRecords(list);
        return Result.ok(page);
    }
}

